package edu.hawaii.duedates.tests;

import junit.framework.TestCase;

  /*
  import static org.junit.Assert.assertEquals;
  import static org.junit.Assert.assertFalse;
  import static org.junit.Assert.assertSame;
  */
  //import static org.junit.Assert.fail;
  import java.util.ArrayList;
  import java.util.List;

  //import org.junit.Ignore;
//import org.junit.Ignore;
import org.junit.Test;

import edu.hawaii.duedates.BookInfoRecord;
import edu.hawaii.duedates.UniversityOfHawaiiLibrary;

/**
 * This test application is a test case for UniversityOfHawaiiLibrary.java that
 * will check for the invalid and valid information.
 * 
 * @author Team Purple John Ancheta, Daniel Arakaki, Mari-Lee Flestado
 *
 */
public class TestUniversityOfHawaiiLibrary extends TestCase {
    
  /**A String for the uhm option. */
  public static final String UHM_OPTION = "-uhm";
    
  /** Instance variable for user id, instantiated to take in command argument. */
  private static final String dueDatesTestUser1Id = System.getenv("DUEDATES_TESTUSER1_ID");

  /** Instance variable for user last name, instantiated to take in command argument. */
  private static final String dueDatesTestUser1LastName = 
                             System.getenv("DUEDATES_TESTUSER1_LASTNAME");
    
  /** Instance variable for user id, instantiated to take in command argument. */
  private static final String dueDatesTestUser2Id = 
                              System.getenv("DUEDATES_TESTUSER2_ID");

  /** Instance variable for user last name, instantiated to take in command argument. */
  private static final String dueDatesTestUser2LastName = 
                              System.getenv("DUEDATES_TESTUSER2_LASTNAME");
    
  /** Unexpected error fail string.*/
  public static final String SHOULD_NOT_FAIL = "Should not fail.";
    
  /** Instance variable for the arrayList bookList.*/
  private static List<BookInfoRecord> bookList = new ArrayList<BookInfoRecord>();
    
  /**
   * Tests for valid ID and last name with UH library.
   */
  @Test
  public void testGetUhValidEntryWithTestUser1() {
    UniversityOfHawaiiLibrary uhmLib = new UniversityOfHawaiiLibrary();  
    try {
      uhmLib.getUhmInfo(dueDatesTestUser1Id, dueDatesTestUser1LastName, bookList);
    }
    catch (Exception e) {
      fail("Unexpected exception thrown, problem with getUhmInfo.");
    }
  }
    
  /**
   * Tests for valid ID and last name with UH library.
   */
  @Test
  public void testGetUhValidEntryWithTestUser2() {
    UniversityOfHawaiiLibrary uhmLib = new UniversityOfHawaiiLibrary();
    try {
      uhmLib.getUhmInfo(dueDatesTestUser2Id, dueDatesTestUser2LastName, bookList);
    }
    catch (Exception e) {
      e.printStackTrace();
      fail("Unexpected exception thrown, problem with getUhmInfo.");
    }
  }
    
  /**
   * Tests for valid ID with format 1234-5678 and last name with UH library.
   */
  @Test
  public void testGetUhmHypenedIdValidEntry() {
    UniversityOfHawaiiLibrary uhmLib = new UniversityOfHawaiiLibrary();
    try {
      String hypenedId = dueDatesTestUser2Id.substring(0, 4) + 
                   "-" + dueDatesTestUser2Id.substring(4);
      uhmLib.getUhmInfo(hypenedId, dueDatesTestUser2LastName, bookList);
    }
    catch (Exception e) {
      e.printStackTrace();
      fail("Unexpected exception thrown, problem with getUhmInfo.");
    }
  }
}
